<?php
	include('zh.php');
	// $link = mysql_connect('localhost','root');
	// $p = mysql_select_db('test',$link);
	// mysql_set_charset('utf8',$link);
	// header("Content-Type:text/html;charset=UTF-8");
	$url1 = 'http://zhaogong.chinalao.com/c_j_dt0_t_k_f0_r0_z0_s0_y0_o0_p1';
	$r1=file_get_contents($url1);
	preg_match("/z0_s0_y0_o0_p(.*?)\">尾页<\/a>/",$r1,$n);
	//print_r($n[1]);
	echo "<br />";
	for($i = 1 ; $i <= 1; $i++)
	{
		$url2 = 'http://zhaogong.chinalao.com/c_j_dt0_t_k_f0_r0_z0_s0_y0_o0_p'.$i;
		$r2=file_get_contents($url2);
		preg_match_all("/http:\/\/info.chinalao.com\/(.*?)\"/",$r2,$m);
		echo "<br />";
		for($j = 1 ; $j < 2; $j++)
		{
			$url3 = "http://info.chinalao.com/".$m[1][$j];
			$r3 = file_get_contents($url3);
			preg_match_all("/\[招工(.*?)info-content-dec/is",$r3,$r4);
			$r=$r4[1][0];
			//print_r($r);
			echo "<br /><br /><br /><br /><br /><br /><br />";
			
			
			if(preg_match_all("/user-info-file\">(.*?)<\/a><\/h2>/is",$r,$company))
			{
				$company[1][0] = strip_tags($company[1][0]);
				$company[1][0] = trim($company[1][0]);
				echo '公司名:'.$company[1][0].'<br />';
				$s[0]=$company[1][0];
			}
			else{$s[0]='不详';}
		
			if(preg_match_all("/](.*?)<\/h1>/i",$r,$vocation))
			{
				echo '职位名称：'.$vocation[1][0].'<br />';
				$s[1]=$vocation[1][0];
			}
			else{$s[1]='不详';}
			
			if(preg_match_all("/所属行业：<\/span>(.*?)<\/li>/i",$r,$industry))
			{
				echo '行业：'.$industry[1][0].'<br />';
				$s[2]=$industry[1][0];
			}
			else{$s[2]='不详';}
			
			if(preg_match_all("/年龄要求：<\/span>(.*?)<\/li>/i",$r,$age))
			{
				echo '年龄要求：'.$age[1][0].'<br />';
				$s[3]=$age[1][0];
			}
			else{$s[3]='无';}
		
			if(preg_match_all("/男女比例：<\/span>(.*?)<\/li>/is",$r,$sex))
			{
				echo '性别要求：'.$sex[1][0].'<br />';
				$s[4]='男:女：'.$sex[1][0];
			}
			else{$s[4]='不详';}
		
			if(preg_match_all("/招聘人数：<\/span>(.*?)人<\/li>/i",$r,$recruit_num))
			{
				echo '招工人数：'.$recruit_num[1][0].'<br />';
				$s[5]=$recruit_num[1][0];
			}
			else{$s[5]='0';}
			
			if(preg_match_all("/基本工资：<\/span>(.*?)元\/月<\/li>/i",$r,$compensation))
			{
				echo '薪资：'.$compensation[1][0].'<br />';
				$s[6]=$compensation[1][0];
			}
			else{$s[6]='0';}
			
			if(preg_match_all("/工作地区：<\/span>(.*?)<\/li>/i",$r,$work_address))
			{
				echo '工作地址：'.$work_address[1][0].'<br />';
				$s[7]=$work_address[1][0];
			}
			else{$s[7]='不详';}
			
			if(preg_match_all("/职位说明：(.*?)<p class=\"clear\">/is",$r,$Job_descriptions))
			{
				$Job_descriptions[1][0] = strip_tags($Job_descriptions[1][0]);
				$Job_descriptions[1][0] = trim($Job_descriptions[1][0]);
				echo '职位描述：'.$Job_descriptions[1][0].'<br />';
				echo "<br /><br /><br />";
				$s[8]=$Job_descriptions[1][0];
			}
			else{$s[8]='职位描述暂未添加';}
			if(preg_match_all("/background:url\((.*?)\) no-repeat/is",$r,$phone_url))
			{
				$filename =$phone_url[1][0];
				$newim="./new.jpeg";
				$im = imagecreatefromjpeg($filename); 
				$new = imagecreatetruecolor(132, 25); 
				imagecopyresampled($new, $im,0,0,0,0,132,25,152,24); 
				imagejpeg($new,$newim); 
				
				$imgPath = "./1.jpeg";
				$gjPhone = new gjPhone($imgPath);
				//进行颜色分离
				$gjPhone->getHec();
				//画出横向数据
				$horData = $gjPhone->magHorData();
				echo "===============横向数据==============<br/><br/><br/>";
				$gjPhone->drawWH($horData);
				// 画出纵向数据
				$verData = $gjPhone->magVerData($horData);
				echo "<br/><br/><br/>===============纵向数据==============< br/><br/><br/>";
				$gjPhone->drawWH($verData);
				$phone = $gjPhone->showPhone($verData);
				echo "<br/><br/><br/>===============电话==============<br /><br/><br/>".$phone;
			}
		}
	}
?>